package routers

import (
	"book/handlers"
	"github.com/gin-gonic/gin"
	"gorm.io/gorm"
)

func MiddleWera() gin.HandlerFunc {
	return func(c *gin.Context) {
		c.Writer.Header().Set("Access-Control-Allow-Origin", "*")
		c.Next()
	}
}
func SetupRouter(db *gorm.DB) *gin.Engine {
	r := gin.Default()
	r.Use(MiddleWera())
	r.POST("/user/login", handlers.UserLogin(db))
	r.GET("/books/list", handlers.List(db))
	return r
}
